package com.hdax.dm.utils.response;

import com.hdax.dm.exception.DmException;

public class ResponseUtil {

    //成功响应数据
    public static<T> CommonResponse<T> returnSuccess(T data){
        return new CommonResponse<>(data);
    }

    //成功响应数据
    public static<T> CommonResponse<T> returnSuccess(T data,String msg){
        return new CommonResponse<>(data,msg);
    }

    //失败响应数据
    public static<T> CommonResponse<T> returnFail(String errorCode,String msg){
        return new CommonResponse<>(errorCode,msg);
    }

    //失败响应数据,异常码
    public static<T> CommonResponse<T> returnFail(DmException e){
        return new CommonResponse<>(e.getErrorCode(),e.getMessage());
    }

}
